/******************************************************************************/
/*  mbrtu.h                                                                   */
/*                                                                            */
/*  FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. */
/*  Copyright (c) 2006 Christian Walter <wolti@sil.at>                        */
/*  All rights reserved.                                                      */
/******************************************************************************/

#ifndef __MB_RTU_H
#define __MB_RTU_H


#ifdef __cplusplus
  PR_BEGIN_EXTERN_C
#endif


#include "Device\device.h"


/******************************************************************************/
/*      Modbus RTU functions                                                  */
/******************************************************************************/
eMB_ERROR_CODE MbRtuInit(const uint8_t _slaveAddress,
                         const uint32_t _baudRate,
                         const eMB_PARITY _parity);

void MbRtuStart(void);

void MbRtuStop(void);

eMB_ERROR_CODE MbRtuReceive(uint8_t * _pRcvAddress,
                            uint8_t ** _pFrame,
                            uint16_t * _pLength);

eMB_ERROR_CODE MbRtuSend(const uint8_t _slaveAddress,
                         const uint8_t * const _pFrame,
                         const uint16_t _Length);

void xMbRtuSetLink(const __eLINK_DEVICE _link);

bool_t xMbRtuReceiveFSM(const uint8_t _xByte);

bool_t xMbRtuTransmitFSM(void);

void xMbRtuTimerT35Expired(void);


#ifdef __cplusplus
  PR_END_EXTERN_C
#endif


#endif